home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 6857 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.7 KB  |  46 lines

  1. Path: sun001.spd.dsccc.com!spd!jmccarty
  2. From: jmccarty@spd.dsccc.com (Mike McCarty)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Watch out! C "gotcha!"
  5. Date: 15 Feb 1996 19:41:43 GMT
  6. Organization: DSC Communications Corporation, Plano, Texas USA
  7. Message-ID: <4g029n$hpd@sun001.spd.dsccc.com>
  8. References: <4fthhh$7th@blackice.winternet.com> <1996Feb15.021301.2697@cannon.interramp.com>
  9. NNTP-Posting-Host: aplo139.spd.dsccc.com
  10.  
  11. In article <1996Feb15.021301.2697@cannon.interramp.com>,
  12. Ronald C. McFarland <rcm@one.net> wrote:
  13. )mschwarz@winternet.com (Michael Schwarz) is astonished to find that:
  14. )
  15. )> [plain 'ol C labels can be embedded (and used) inside of switch statements]
  16. )>
  17. )>Does anyone know of:
  18. )>
  19. )> [snip]
  20. )>
  21. )>3)    The ANSI party line on labels -- is there an ANSI enforcement option
  22. )>    that guarantees a warning on a construct like this?  (If not, does
  23. )>    anyone know how to suggest revisions to the X3-J11 standard?)
  24. )
  25. )Labels embedded inside the body of "switch" statements are perfectly legal.
  26. )This has always been true and, if you think about it, is no different than
  27. )embedding labels inside the bodies of "for" statements, "while" statements,
  28. )or what-have-you statements.
  29.  
  30. [cut]
  31.  
  32. But there are languages which would catch this type of error. C is
  33. better than Fortran in this respect, because it forces declaration of
  34. variables. Unfortunately, in C, labels are self-declaring as are
  35. variables in Fortran. This is a defect in the language, but one which we
  36. must live with or choose another language. Pascal is superior to C in
  37. this respect.
  38.  
  39. I'm not trying to start a "my language is better than yours" thread.
  40.  
  41. Mike
  42. ----
  43. char *p="char *p=%c%s%c;main(){printf(p,34,p,34);}";main(){printf(p,34,p,34);}
  44.  
  45. I don't speak for DSC.         <- They make me say that.
  46.